using System.Windows.Forms;
using pub.CmdUI.Cmd;
using pub.CmdUI.UI.Control;

namespace todo.Cmd.Edit
{
    public class DeleteCmd : DefaultCmd, ICmdState
    {
        public DeleteCmd()
        {
            Shortcut = new CmdShortcut(Keys.Delete);
        }

        bool ICmdState.Enabled
        {
            get { return TodoApi.Instance.HasSelection; }
        }

        public override void Execute(IControlUI controlUi)
        {
            if (TodoApi.Instance.IsEditing() ?? false)
            {
                TodoApi.Instance.PasteText("");
                return;
            }
            TodoApi.Instance.Delete();
        }
    }
}